package org.lanqiao.ssm.common.redis.cluster;

import java.util.HashSet;
import java.util.Set;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;

/**
 * 
 * @描述:
 * @作者: wei.liu
 * @创建时间: 2016年10月8日
 * @版本: 1.0
 */
public class RedisClusterTest {

	public static void main(String[] args) throws InterruptedException {
	/*	final ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
				"spring/redis-cluster.xml");
		ctx.start();
		JedisCluster jedisCluster = (JedisCluster) ctx.getBean("jedisCluster");

		jedisCluster.set("foo1", "2");
		System.out.println(jedisCluster.get("foo"));*/
		Set<HostAndPort> set = new HashSet<HostAndPort>();
		set.add(new HostAndPort("10.1.254.144", 7000));
		set.add(new HostAndPort("10.1.254.144", 7001));
		set.add(new HostAndPort("10.1.254.144", 7002));

		JedisCluster jc = new JedisCluster(set, 10000, 20);
		jc.set("foo1", "2");
		System.out.println(jc.get("foo"));
	}

}